package casts.audio
{
   import com.greensock.TweenMax;
   
   import flash.display.MovieClip;
   import flash.events.Event;
   import flash.events.MouseEvent;
   import flash.media.SoundMixer;
   
   public class AudioButton extends MovieClip
   {
      
      public function AudioButton()
      {
         super();
         
         stop();
         
         addEventListener(Event.ADDED_TO_STAGE, onAdd);
         addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
      }
      
      // --------------------- LINE ---------------------
      
      // ################### protected ##################
      
      // #################### private ###################
      
      private function onAdd(e:Event):void
      {
         addEventListener(MouseEvent.CLICK, changeVolume);
      }
      
      private function onRemove(e:Event):void
      {
         removeEventListener(MouseEvent.CLICK, changeVolume);
      }
      
      // --------------------- LINE ---------------------
      
      private function changeVolume(e:MouseEvent):void
      {
         if (currentFrame == 1)
         {
            gotoAndStop(2);
            
            TweenMax.to(SoundMixer, 1, { volume:0 } );
         }
         else
         {
            gotoAndStop(1);
            
            TweenMax.to(SoundMixer, 1, { volume:1 } );
         }
      }
      
      // --------------------- LINE ---------------------
      
   }
   
}